package com.micro.school.edu.controller;

import java.util.List;

import com.micro.school.edu.domain.vo.CollegeModelVo;
import com.micro.school.edu.domain.vo.SchoolCollegeVo;
import com.micro.school.edu.service.ISchoolCollegeService;
import com.micro.school.common.core.utils.poi.ExcelUtil;
import com.micro.school.common.core.web.controller.BaseController;
import com.micro.school.common.core.web.domain.AjaxResult;
import com.micro.school.common.core.web.page.TableDataInfo;
import com.micro.school.common.log.enums.BusinessType;
import com.micro.school.common.security.annotation.RequiresPermissions;
import com.micro.school.system.api.domain.vo.SchoolCollegeVos;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.micro.school.common.log.annotation.Log;

/**
 * 学院信息Controller
 *
 * @author rakic
 * @date 2025-08-06
 */
@RestController
@RequestMapping("/college")
public class SchoolCollegeController extends BaseController
{
    @Autowired
    private ISchoolCollegeService schoolCollegeService;

    /**
     * 查询学院信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SchoolCollegeVo schoolCollegeVo)
    {
        startPage();
        List<SchoolCollegeVo> list = schoolCollegeService.selectSchoolCollegeList(schoolCollegeVo);
        return getDataTable(list);
    }
    /**
     * 查询列表不分页
     */
    @PostMapping("/getSchoolCollegeLists")
    public  AjaxResult getSchoolCollegeLists(@RequestBody SchoolCollegeVos schoolCollegeVos)
    {
        List<SchoolCollegeVos> list = schoolCollegeService.selectSchoolCollegeLists(schoolCollegeVos);
        return success(list);
    }

    /**
     * 查询列表不分页
     */
    @PostMapping("/getSchoolCollegeLists1")
    public  AjaxResult getSchoolCollegeLists1(@RequestBody SchoolCollegeVos schoolCollegeVos)
    {
        List<SchoolCollegeVos> list = schoolCollegeService.selectSchoolCollegeLists1(schoolCollegeVos);
        return success(list);
    }

    /**
     * 查询列表不分页
     */
    @PostMapping("/getAllCollegeNameList")
    public  AjaxResult getAllCollegeNameList(@RequestBody SchoolCollegeVo schoolCollegeVo)
    {
        String collegeNames = schoolCollegeService.getAllCollegeNameList(schoolCollegeVo.getCollegeId());
        return success(collegeNames);
    }

    /**
     * 查询列表不分页
     */
    @GetMapping("/getSchoolCollegeList")
    public  AjaxResult getSchoolCollegeList(SchoolCollegeVo schoolCollegeVo)
    {
        List<SchoolCollegeVo> list = schoolCollegeService.selectSchoolCollegeList(schoolCollegeVo);
        return success(list);
    }
    /**
     * 导出学院信息列表
     */
    @Log(title = "学院信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SchoolCollegeVo schoolCollegeVo)
    {
        List<SchoolCollegeVo> list = schoolCollegeService.selectSchoolCollegeList(schoolCollegeVo);
        ExcelUtil<SchoolCollegeVo> util = new ExcelUtil<SchoolCollegeVo>(SchoolCollegeVo.class);
        util.exportExcel(response, list, "学院信息数据");
    }

    /**
     * 获取学院信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(schoolCollegeService.selectSchoolCollegeById(id));
    }

    /**
     * 获取学院信息详细信息
     */
    @GetMapping(value = "/feign/{id}")
    public AjaxResult getFeignInfo(@PathVariable("id") Long id)
    {
        return success(schoolCollegeService.selectSchoolCollegeByIds(id));
    }

    /**
     * 新增学院信息
     */
    @Log(title = "学院信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SchoolCollegeVo schoolCollegeVo)
    {
        return schoolCollegeService.insertSchoolCollege(schoolCollegeVo);
    }

    /**
     * 修改学院信息
     */
    @Log(title = "学院信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SchoolCollegeVo schoolCollegeVo)
    {
        return toAjax(schoolCollegeService.updateSchoolCollege(schoolCollegeVo));
    }

    /**
     * 删除学院信息
     */
    @Log(title = "学院信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        SchoolCollegeVo schoolCollegeVo=new SchoolCollegeVo();
        schoolCollegeVo=schoolCollegeService.selectSchoolCollegeById(ids.get(0));
        schoolCollegeVo.setDeleteFlag("1");
        return toAjax(schoolCollegeService.updateSchoolCollege(schoolCollegeVo));
    }
//    public AjaxResult remove(@PathVariable List<Long> ids)
//    {
//        return toAjax(schoolCollegeService.deleteSchoolCollegeByIds(ids));
//    }


}
